import {useReducer} from 'react';

const initialState = {
    name : "thd",
    age:5
}


const reducer = (state, action) => {
    switch (action.type) {
      case 'setName':
        return {...state,name:action.payload.name};
      case 'setAge':
        return {...state,age:action.payload.age};
      default : 
        throw new Error(" action is not existed !");
    }
};

const useMyReducer = () => {
    return useReducer(reducer, initialState);
};

export default useMyReducer;
